<?php

	/**
	 *  Class to handle login
	 */	
		   
	class LoginView
	{
		private $m_getName = "name";
		private $m_getPassword = "password";
		private $m_getLogin = "login";
		private $m_getRemember = "rememberme";
		private $m_getLogout = "logout";
		 
		private static $nameCookie = "nameCookie";
		private static $passwordCookie = "passwordCookie";
				 
		//Function to return loginform
		 public function DoLoginBox()
		 {
    		$form = "<form method='post' action='' class='form1'>
			<input type='text' name='$this->m_getName' /> Name<br />
			<input type='password' name='$this->m_getPassword' /> Password<br />
			<p class='submit'><input type='submit' name='$this->m_getLogin' value='Login' /></p>
			<input type='checkbox' name='rememberme' value='remember' /> Remember me?  
			</form>";
						
			return $form;
		 }
		 
		 //Function to return logout button
		 public function DoLogoutBox()
		 {
		 	$logoutButton = "<form method='post' action=''>
		 	<p class='logout'><input type='submit' value='Log out' name='$this->m_getLogout' /></p>
		 	</form>";
			
			return $logoutButton;
		 }
		 
		 //Function to return username input
		 public function GetUserName()
		 {
		 	$a_name = $_POST[$this->m_getName];
			
		 	if (trim($a_name) == "" ) {
		 		$a_name = null;
			}
			 
		 	return $a_name;
		 }
		 
		 //Function to return user password input
		 public function GetPassword()
		 {
		 	$a_password = $_POST[$this->m_getPassword];
			
			if (trim($a_password) == "" ) {
		 		$a_password = null;
			}
			
			return $a_password;
		 }
		 
		 //Function to return if user pressed login or not
		 public function TriedToLogIn()
		 {
		 	if (isset($_POST['login'])) {		 						
				 return true;
			} else {
				 return false;
			}
		 }
		 
		  //Function to return if user pressed logout
		 public function TriedToLogout()
		 {
		 	if (isset($_POST[$this->m_getLogout])) {
				return true;
			 } else {
				return false; 
			 }
		 }
	}
	
